﻿package com.msjt.dao;

import java.util.List;

import com.msjt.base.BaseDAO;
import com.msjt.entity.NewJob;
/**
 * name:NewsJobDAO
 * function:招聘信息模块数据层
 * author: kw
 * time:2013.8.27
 * updateTime:
 */
public class NewJobDAO extends BaseDAO {
	//添加招聘信息
	public boolean addNewJob(NewJob newJob){
		return this.save(newJob);
	}
	//删除招聘信息
	public boolean deleteNewJob(NewJob newJob){
		return this.deleteById(newJob.getJobId());
	}
	//修改招聘信息
	public boolean updateNewJob(NewJob newJob){
		return this.saveOrUpdate(newJob);
	}
	//分页显示招聘信息,前台显示招聘信息的全部
	@SuppressWarnings("unchecked")
	public List<NewJob> getNewJobByIndex(int pageIndex,int pageSize){
		String hql="select job from NewJob as job order by job.jobDate desc";
		return (List<NewJob>) this.searchByPage(hql, null, pageIndex, pageSize);
	}
	//分页显示招聘信息，后台只显示招聘信息的职位,日期，截至日期
	@SuppressWarnings("unchecked")
	public List<NewJob> getNewJobByAfter(int pageIndex,int pageSize){
		String hql="select new NewJob(job.jobId,job.jobName,job.jobDate,job.jobOverDate) from NewJob as job order by job.jobDate desc";
		return (List<NewJob>) this.searchByPage(hql, null, pageIndex, pageSize);
	}
	//根据ID查找招聘信息
	public NewJob getNewJobById(NewJob newJob){
		return (NewJob) this.findById(newJob.getJobId());
	}
	//计算总个数
	public Integer getJobCount(){
		String hql="select count(n.jobId) from NewJob as n";
		return this.getTotalCount(hql, null);
	}
	/**
	 * 批量删除
	 * @param idString id的字符串，用“,”号隔开
	 * @return
	 */
	public boolean deleteMore(String idString){
		String hql="delete NewJob as newJob where newJob.jobId in ("+idString+")";
		return this.updateByHql(hql, null);
	}
	
}
